using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Media;
using System.Windows;

namespace Starter3DGameEngine
{
    public static class AudioEngine
    {

        //Ship Audio Effects
        public static SoundEffect Engine;
        public static SoundEffectInstance EngineInstance;
        public static SoundEffect Shot;

        //Environmental Effects
        public static SoundEffect ExplosionShip;
        public static SoundEffect ExplosionAsteroid;
        public static SoundEffect HyperSpace;

        //Music
        public static SoundEffect Music;
        public static SoundEffectInstance MusicInstance;

        public static void LoadContent(ContentManager contentManager)
        {
            //Load Audio
            Engine = contentManager.Load<SoundEffect>(@"Audio\EngineSound");
            EngineInstance = Engine.CreateInstance();
            EngineInstance.IsLooped = true;

            Shot = contentManager.Load<SoundEffect>(@"Audio\Fire");
            ExplosionShip = contentManager.Load<SoundEffect>(@"Audio\ExplosionShip");
            ExplosionAsteroid = contentManager.Load<SoundEffect>(@"Audio\ExplosionAsteroid");
            HyperSpace = contentManager.Load<SoundEffect>(@"Audio\hyperspace_activate");

            Music = contentManager.Load<SoundEffect>(@"Audio\Music");
            MusicInstance = Music.CreateInstance();
            MusicInstance.Volume = 0.5f;
            MusicInstance.IsLooped = true;
        }

        public static void StartBackgroundMusic()
        {
            if (MediaPlayer.GameHasControl)
            {
                MusicInstance.Play();
            }
            //else
            //{
            //    if (!GameConstants.UserPromptedAlready)
            //    {
            //        if (MessageBox.Show("Is it ok to stop currently playing music and play the in game music?", "Can play in game music?",
            //MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            //        {
            //            MediaPlayer.Pause();
            //            MusicInstance.Play();
            //        }
            //        GameConstants.UserPromptedAlready = true;
            //    }
            //}
        }

        

    }
}
